import collections

D_INPUT = True
if D_INPUT:
    s = raw_input().split()
else:
    s = "qwe sdf tyu qwe sdf try sdf qwe sdf rty sdf wer sdf wer".split()

d = collections.OrderedDict()
for i in xrange(len(s)) :
    word = s[i]
    if d.get(word) == None :
        d[word] = 1
    else :
        d[word] = i


for item in d.items() :
    if item[1] != 1 : 
        print str(item[0])+"("+str(item[1])+")",
    else : 
        print str(item[0]),








# unique = []
# count = []    
# for i in xrange(len(str)) :
#     for j in xrange(len(unique)) :
#         if str[i] == unique[j] :
#             count[j] = i
#             break
#     else :
#         unique.append(str[i])
#         count.append(-1)
#         
# for i in xrange(len(unique)) :
#     str = unique[i]
#     if count[i] != -1 : str +="(" +"%d" % count[i]+")"
#     print str,

